package de.uni.muenster.idw2.dialogs;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Display;
import android.view.Window;
import android.widget.Gallery;
import android.widget.ImageView;

public class ImageDialog extends Dialog{

	private final Drawable img;
	private final Context context;

	public ImageDialog(Context context, Drawable img) {
		super(context);
		this.context = context;
		this.img = img;
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		ImageView im = new ImageView(context);
		im.setImageDrawable(img);
		
		int hight = img.getMinimumHeight();
        int width = img.getMinimumWidth();
        
        double diff = width/((double)hight);
        
        Display display = ((Activity) context).getWindowManager().getDefaultDisplay(); 
        int displayWidth =(int) (display.getHeight());
        
        im.setLayoutParams(new Gallery.LayoutParams((int)(displayWidth * diff), displayWidth));
        
		
		
		setContentView(im);
	}

}
